﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hook.Graphics;
using Hook.Graphics.SpriteSheets;
using Microsoft.Xna.Framework;

namespace Hook.Environmental.Props
{
    class ChainHead : Prop
    {
        public bool Rooted;
        public Prop RootProp;

        public ChainHead()
            : base()
        {
            Sprite = new Sprite(Game1.PropSheet, PropSheet.WHEEL);
            Sprite.Scale = .1f;

            List<Vector3> VO = new List<Vector3>();

            VO.Add(new Vector3(25, 0, 0));
            VO.Add(new Vector3(0, 25, 0));
            VO.Add(new Vector3(-25, 0, 0));
            VO.Add(new Vector3(0, -25, 0));

            Frame.SetPoints(VO);

            Mass = 20;
            Inertia = 20000;
            GravityOn = false;
            CollisionLayer.Add(1);

            LoadPropData("ChainHead.txt");
        }

        public void Root(Prop P)
        {
            RootProp = P;
            RootProp.RootedTo = true;
            Velocity = AngularVelocity = Vector3.Zero;
            Mass = float.PositiveInfinity;
            Inertia = float.PositiveInfinity;
            CollisionLayer.Clear();
            Rooted = true;
        }

        public void UnRoot()
        {
            Mass = 20;
            Inertia = 20000;
            Rooted = false;
            if (RootProp != null)
            {
                RootProp.RootedTo = false;
            }
        }

        public void FollowRoot()
        {
            if (Rooted)
            {
                Velocity = RootProp.Velocity;
            }
        }
    }
}
